﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineCooperation.Entity;
using OnlineCooperation.DB;

namespace OnlineCooperation
{
    public partial class SetupTeam : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ButtonSetupTeamClick(object sender, EventArgs e)
        {
            string name = SetTeamName.Value;
            if (name == "")
            {
                Response.Write("<script>alert('团队名不能为空！')</script>");
                return;
            }
            string des = TeamDescription.Value;
            Team t = new Team(0, name, des, int.Parse(Session["UserID"].ToString()));
            TeamDB td = new TeamDB();
            int code=td.Insert(t);
            if (code == 0)
            {
                Response.Write("<script>alert('团队名已存在！')</script>");
                return;
            }
            else
            {
                Response.Write("<script>alert('团队创建成功！');window.location='TeamIndex.aspx';</script>");
                return;
            }
        }
    }
}